﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OnlineTestBLL;
using OnlineTestModel;
using FineUI;

namespace OnlineTestUI.BackManager
{
    public partial class editpaper : System.Web.UI.Page
    {
        protected QuestionItemsBLL qib = new QuestionItemsBLL();
        protected List<PaperQuestionEx> PqeList=new List<PaperQuestionEx>();
        protected List<PaperQuestionEx> ChoiceQuestionList = new List<PaperQuestionEx>();
        protected List<PaperQuestionEx> TofQuestionList = new List<PaperQuestionEx>();
        protected List<PaperQuestionEx> ShortQuestionList = new List<PaperQuestionEx>();
        protected List<PaperQuestionEx> CompletionQuestionList = new List<PaperQuestionEx>();
        protected PapersBLL pb = new PapersBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["teacher"] != null)
            {

                if (!IsPostBack)
                {
                    if (Request.QueryString["id"] != null)
                    {
                        int id = Convert.ToInt32(Request.QueryString["id"]);
                        BindToData(id);
                    }
                }
            }
            else
            {
                Response.Redirect("login.aspx");
            }
            
        }

        private void BindToData(int id)
        {
            Papers p = pb.GetModel(id);
            QuestionsBLL qb = new QuestionsBLL();
            PqeList = qb.GetListByPaperId(" =" + id.ToString() + " order by questiontypeid,bigquestion,smallquestion,id");
            ChoiceQuestionList =
                PqeList.Where(s => s.QuestionTypeId == Convert.ToInt32(OnlineTestCOMMON.EnumType.QuestionTypeId.Choice))
                       .ToList();
            TofQuestionList =
                PqeList.Where(s => s.QuestionTypeId == Convert.ToInt32(OnlineTestCOMMON.EnumType.QuestionTypeId.ToF))
                       .ToList();
            CompletionQuestionList =
                PqeList.Where(s => s.QuestionTypeId == Convert.ToInt32(OnlineTestCOMMON.EnumType.QuestionTypeId.Completion))
                       .ToList();
            ShortQuestionList =
                PqeList.Where(s => s.QuestionTypeId == Convert.ToInt32(OnlineTestCOMMON.EnumType.QuestionTypeId.Short))
                       .ToList();
        }

        //protected void BtAdd_Click(object sender, EventArgs e)
        //{
        //    if (String.IsNullOrEmpty(Request.QueryString["id"]))
        //    {
        //        pb.UpdateFinish(Convert.ToInt32(Request.QueryString["id"]));
        //        Alert.Show("试卷发布完成");
        //        PageContext.Redirect("default.aspx");
        //    }
            
        //}



    }
}